var crypto = require('../utils/crypto');
var express = require('express');
var db = require('../db');
//var http = require("../utils/http");

var app = express();
//var hallAddr = "";

function send(res,ret){
    var str = JSON.stringify(ret);
    res.send(str)
}

var config = null;

//设置跨域访问
app.all('*', function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "X-Requested-With");
    res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
    res.header("X-Powered-By",' 3.2.1')
    res.header("Content-Type", "application/json;charset=utf-8");
    next();
});

exports.start = function(cfg){
    config = cfg;
    //hallAddr = config.IP  + ":" + config.HALL_CLIENT_PORT;
    app.listen(config.CLEINT_PORT);
    console.log("account server is listening on " + config.CLEINT_PORT);
}

function check_account(req, res) {
    var account = req.query.account;
    var password = req.query.password;
    if (account == null || password == null) {
        http.send(res, 1, "unknow error!");
        return false;
    }
    return true;
}

app.get('/login', function(req, res) {
    //1. 检测账号
    //2.
})

